package cn.tedu.home1ess.admin.content.dao.repository.impl;


import cn.tedu.home1ess.admin.content.dao.mapper.TabooCategoryMapper;
import cn.tedu.home1ess.admin.content.dao.mapper.TabooContentMapper;
import cn.tedu.home1ess.admin.content.dao.repository.ITabooRepository;
import cn.tedu.home1ess.admin.content.pojo.po.TabooWordsCategorytPO;
import cn.tedu.home1ess.admin.content.pojo.po.TabooWordsContentPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TabooRepositoryImpl implements ITabooRepository {
    @Autowired
    private TabooContentMapper tabooContentMapper;

    @Autowired
    private TabooCategoryMapper tabooCategoryMapper;

    @Override
    public List<TabooWordsContentPO> selectContent() {
        QueryWrapper queryWrapper=new QueryWrapper();

        return tabooContentMapper.selectList(queryWrapper);
    }

    @Override
    public TabooWordsCategorytPO selectCategoryById(Long id) {

        return tabooCategoryMapper.selectById(id);
    }



    @Override
    public List<TabooWordsCategorytPO> selectCategoryByParentId(Long parentId) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("parent_id",parentId);
        return tabooCategoryMapper.selectList(queryWrapper);
    }

    @Override
    public void addTaboo(TabooWordsContentPO tabooWordsContentPO) {
        tabooContentMapper.insert(tabooWordsContentPO);
    }

    @Override
    public TabooWordsContentPO selectContentById(Long id) {
        return tabooContentMapper.selectById(id);
    }

    @Override
    public void updateTaboo(TabooWordsContentPO tabooWordsContentPO) {
        tabooContentMapper.updateTaboo(tabooWordsContentPO);
    }

    @Override
    public void deleteContentById(Long id) {
        tabooContentMapper.deleteById(id);
    }
}
